﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReceivablesReport.aspx.cs"
    Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <link rel="stylesheet" href="Assets/css/EditTableCell.css" type="text/css" />
    <script type='text/javascript' src="Assets/js/jquery-custom-1.0.0.js?v=2011"></script>
    <script type='text/javascript' src="assets/js/ReceivablesReport.js"></script>
    <link rel="stylesheet" type="text/css" href="assets/css/datepicker.css" />
    <script type='text/javascript' src="assets/js/jquery.ui.datepicker.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txtFrom").datepicker({ dateFormat: "dd-mm-yy" });
            $("#txtTo").datepicker({ dateFormat: "dd-mm-yy" });
            $("#txtFromPayment").datepicker({ dateFormat: "dd-mm-yy" });
            $("#txtToPayment").datepicker({ dateFormat: "dd-mm-yy" });
            $("#btnExport").click(function () {
                openwindow();
            });
        });
        function openwindow() {
            window.open("./ReceivablesReport.Export.aspx?action=export", "mywindow", "menubar=0,status=0,directories=0,resizable=1,scrollbars=1,width=720,height=500");
        }
    </script>
    <style type="text/css">
        .thheader1{
        font-weight:bold;vertical-align:middle;text-align:center;
        font-size:11px;
        border:1px solid #ccc !important;
        line-height: 7px !important;;
        }
        .bottom td
        {
         font-weight:bold;
         text-align:left;
        }
    </style>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2>
                BÁO CÁO PHẢI THU KHÁCH HÀNG
            </h2>
            <div class="clear">
            </div>
            <div class="content-box">
                <form id="frmEdit" runat="server">
                <div class="content-box-header" style="height: auto;">
                    <h3 style="cursor: s-resize;">
                        <% =Province%>
                    </h3>
                    <%if (nPermissions > 7)
                          { %>
                    <asp:DropDownList ID="ddProvince" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddProvince_SelectedIndexChanged">
                    </asp:DropDownList>
                    <%} %>
                    <%--<b class="red">Overdue</b><asp:CheckBox Text="" ID="cbExpired" AutoPostBack="true"
                            runat="server" OnCheckedChanged="cbExpired_CheckedChanged" />
                    --%>
                    <asp:DropDownList ID="ddExpired" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddExpired_SelectedIndexChanged">
                        <asp:ListItem Text="Debt status" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Overdue" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Near Overdue" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp; Find:<asp:TextBox ID="keyword" Text="" runat="server"></asp:TextBox>
                    By:
                    <asp:DropDownList ID="ddType" runat="server">
                        <asp:ListItem Text="File Number" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Carrier" Value="2"></asp:ListItem>
                        <asp:ListItem Text="Customer" Value="3"></asp:ListItem>
                        <asp:ListItem Text="POL" Value="4"></asp:ListItem>
                        <asp:ListItem Text="POD" Value="5"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddCustomerOwesStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddCustomerOwesStatus_SelectedIndexChanged">
                        <asp:ListItem Text="Receivable status" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Receivables" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Collected" Value="2"></asp:ListItem>
                        <asp:ListItem Text="In Seaching" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddSearchCustomer" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddSearchCustomer_SelectedIndexChanged"
                        Width="150px">
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddComOwesStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddComOwesStatus_SelectedIndexChanged">
                        <asp:ListItem Text="COM status" Value="0"></asp:ListItem>
                        <asp:ListItem Text="COM not paid" Value="1"></asp:ListItem>
                        <asp:ListItem Text="COM paid" Value="2"></asp:ListItem>
                        <asp:ListItem Text="COM verified" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddPaid" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddPaid_SelectedIndexChanged">
                        <asp:ListItem Text="Carr payment" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Paid" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Not paid" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:TextBox ID="txtFrom" CssClass="calendar-icon" runat="server" value="From ATD"
                        onclick="if(this.value=='From ATD'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='From ATD'; this.style.color='#555'}" Width="125px"></asp:TextBox>
                    <asp:TextBox ID="txtTo" CssClass="calendar-icon" runat="server" value="To ATD" Width="125px"
                        onclick="if(this.value=='To ATD'){this.value=''; this.style.color='#000'}" onblur="if(this.value==''){this.value='To ATD'; this.style.color='#555'}"></asp:TextBox>
                    <asp:TextBox ID="txtFromPayment" CssClass="calendar-icon" runat="server" value="From Payment"
                        onclick="if(this.value=='From Payment'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='From Payment'; this.style.color='#555'}"
                        Width="125px"></asp:TextBox>
                    <asp:TextBox ID="txtToPayment" CssClass="calendar-icon" runat="server" value="To Payment"
                        Width="125px" onclick="if(this.value=='To Payment'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='To Payment'; this.style.color='#555'}"></asp:TextBox>
                    &nbsp;<asp:Button ID="btnSearch" runat="server" Text="&nbsp;Seach&nbsp;" CssClass="button"
                        OnClick="btnSearch_Click" />
                    <%if(nPermissions > 7){ %>
                    <input id="btnExport" type="button" style="float: right; margin: 9px 10px;" class="button"
                        value="&nbsp;Export&nbsp;" />
                    <asp:Button ID="btnCloseFile" Style="float: right; margin: 9px 10px;" CssClass="button"
                        runat="server" Text="&nbsp;Close&nbsp;" OnClick="btnCloseFile_Click" />
                    <%} %>
                    <div class="clear">
                    </div>
                </div>
                <asp:Repeater ID="rptData" runat="server" OnItemDataBound="rptData_ItemDataBound">
                    <ItemTemplate>
                        <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'"
                            receivablesreport='<%#Eval("ID") %>'>
                            <td>
                                <asp:TextBox ID="txtID" runat="server" Text='<%#Eval("ID") %>' Style="display: none;
                                    width: 50px !important;"></asp:TextBox>
                                <%# DataBinder.Eval(Container.DataItem, "Index")%>
                            </td>
                            <td editable="false" width="250px;">
                                <%# DataBinder.Eval(Container.DataItem, "Customer")%>
                            </td>
                            <td editable="false" code="FileNumber" style="width: 50px; text-align: center;">
                                <%# DataBinder.Eval(Container.DataItem, "FileNumber")%>
                            </td>
                            <td editable="false" code="POL" style="width: 100px;">
                                <%# DataBinder.Eval(Container.DataItem, "POL")%>
                            </td>
                            <td editable="false" code="POD" style="width: 100px;">
                                <%# DataBinder.Eval(Container.DataItem, "POD")%>
                            </td>
                            <td editable="false" code="ETD">
                                <%# DataBinder.Eval(Container.DataItem, "ETD")%>
                            </td>
                            <td editable="false" code="TotalSellInvoice">
                                <%# DataBinder.Eval(Container.DataItem, "TotalSellInvoice")%>
                            </td>
                            <td editable="true" code="Receivables_Obtained" style="width: 100px;">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_Obtained")%>
                            </td>
                            <td editable="false" code="Receivables_Must_Obtained">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_Must_Obtained")%>
                            </td>
                            <td editable="false" code="TotalComCustomer">
                                <%# DataBinder.Eval(Container.DataItem, "TotalComCustomer")%>
                            </td>
                            <td editable="false" code="TotalTaxCustomer">
                                <%# DataBinder.Eval(Container.DataItem, "TotalTaxCustomer")%>
                            </td>
                            <td editable="false" code="ComAfterTax">
                                <%# DataBinder.Eval(Container.DataItem, "ComAfterTax")%>
                            </td>
                            <td editable="true" code="Receivables_Paid_Com" style="width: 100px;">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_Paid_Com")%>
                            </td>
                            <td editable="false" code="Receivables_Must_Paid_Com" class='<%#double.Parse(Eval("Receivables_Must_Paid_Com").ToString())<0?" red":" " %>'>
                                <%#double.Parse(Eval("Receivables_Must_Paid_Com").ToString())!=0?double.Parse(Eval("Receivables_Must_Paid_Com").ToString()).ToString("#,#"):""%>
                            </td>
                            <td editable="false" code="Receivables_Must_Paid_Com_Verify">
                                <asp:HiddenField ID="Receivables_Must_Paid_Com_Verify" Value='<%#Eval("Receivables_Must_Paid_Com_Verify") %>'
                                    runat="server" />
                                <asp:CheckBox ID="ReceivablesComVerify" runat="server" AutoPostBack="true" OnCheckedChanged="ReceivablesComVerify_CheckedChanged" />
                            </td>
                            <td editable="false" code="Date_Expiration">
                                <%# DataBinder.Eval(Container.DataItem, "Date_Expiration")%>
                            </td>
                            <td editable="true" code="Receivables_Update">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_Update")%>
                            </td>
                            <td editable="true" code="Receivables_PaymentMethod">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_PaymentMethod")%>
                            </td>
                            <td editable="false" code="Days_Overdue" style="width: 50px; text-align: center;">
                                <%# DataBinder.Eval(Container.DataItem, "Days_Overdue")%>
                            </td>
                            <td editable="false" code="Agent">
                                <%# DataBinder.Eval(Container.DataItem, "Agent")%>
                            </td>
                            <td editable="false" code="PaidStatus">
                                <%# DataBinder.Eval(Container.DataItem, "PaidStatus")%>
                            </td>
                            <td editable="true" code="Receivables_Note" style="width: 100px;">
                                <%# DataBinder.Eval(Container.DataItem, "Receivables_Note")%>
                            </td>
                            <td style="width: 75px;">
                                <%# DataBinder.Eval(Container.DataItem, "Action")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <HeaderTemplate>
                        <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                            editcellcontent="true">
                            <thead>
                                <tr style="background: #ECECEC;">
                                    <th align="center" rowspan="2" class="thheader">
                                        STT
                                    </th>
                                    <th align="center" colspan="5" class="thheader">
                                        Chi tiết
                                    </th>
                                    <th align="center" colspan="3" class="thheader">
                                        Số phải thu khách hàng
                                    </th>
                                    <th align="center" colspan="6" class="thheader">
                                        Thanh toán COM & Thu lại thuế của Khách hàng
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ngày trả
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ngày TT
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        HTTT
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Số ngày quá hạn
                                    </th>
                                    <th align="center" colspan="2" class="thheader">
                                        Nhà cung cấp
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ghi chú
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Chức năng
                                    </th>
                                </tr>
                                <tr style="background: #ECECEC;">
                                    <th align="center" class="thheader">
                                        Khách hàng
                                    </th>
                                    <th align="center" class="thheader">
                                        Số File
                                    </th>
                                    <th align="center" class="thheader">
                                        POL
                                    </th>
                                    <th align="center" class="thheader">
                                        POD
                                    </th>
                                    <th align="center" class="thheader">
                                        ATD
                                    </th>
                                    <th align="center" class="thheader">
                                        Số tiền phải thu
                                    </th>
                                    <th align="center" class="thheader">
                                        Số tiền đã thu
                                    </th>
                                    <th align="center" class="thheader">
                                        Số tiền còn phải thu
                                    </th>
                                    <th align="center" class="thheader">
                                        COM. Khách hàng
                                    </th>
                                    <th align="center" class="thheader">
                                        Thuế thu lại
                                    </th>
                                    <th align="center" class="thheader">
                                        COM. sau thuế
                                    </th>
                                    <th align="center" class="thheader">
                                        COM đã TT
                                    </th>
                                    <th align="center" class="thheader">
                                        COM còn phải trả
                                    </th>
                                    <th align="center" class="thheader">
                                        Duyệt
                                    </th>
                                    <th align="center" class="thheader">
                                        Tên
                                    </th>
                                    <th align="center" class="thheader">
                                        Paid
                                    </th>
                                </tr>
                            </thead>
                    </HeaderTemplate>
                    <FooterTemplate>
                        <tr class="bottom">
                            <td colspan="4">
                            </td>
                            <td colspan="2">
                                Tổng cộng
                            </td>
                            <td>
                                <% =SUM_Ref_Receivables_Must_Obtained %>
                            </td>
                            <td>
                                <% =SUM_Receivables_Obtained %>
                            </td>
                            <td>
                                <%=SUM_Receivables_Must_Obtained %>
                            </td>
                            <td>
                                <%=SUM_Ref_Receivables_Must_Paid_Com %>
                            </td>
                            <td>
                                <%=SUM_Receivables_Tax_Customer %>
                            </td>
                            <td>
                                <%=SUM_ComAfterTax %>
                            </td>
                            <td>
                                <%=SUM_Receivables_Paid_Com %>
                            </td>
                            <td>
                                <%=SUM_Receivables_Must_Paid_Com %>
                            </td>
                            <td colspan="11">
                            </td>
                        </tr>
                        </TABLE>
                    </FooterTemplate>
                </asp:Repeater>
                <div class="clear">
                </div>
                <div id="footer">
                    <%=strPager%>
                </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
